package com.whosly.rapid.data.resp.pojo.response;

import com.whosly.api.constant.Constants;
import com.whosly.api.page.PageList;
import lombok.Getter;
import lombok.Setter;

/**
 * 分页相应实体
 *
 * @author yueny(yueny09@163.com)
 * @param <T>
 *            实体类型
 *
 * @date 2015年10月19日 上午10:12:04
 */
public class PageListResponse<T> extends BaseResponse {

	/**
	 *
	 */
	private static final long serialVersionUID = 8934059480046483594L;

	/**
	 * 请求返回实体
	 */
	@Getter
	@Setter
	private PageList<T> list;

	/**
	 *
	 */
	public PageListResponse() {
		super();
		list = new PageList<T>();
	}

	public PageListResponse(String code, String message, PageList<T> data) {
		super(code, message);
		this.list = data;
	}

	public static PageListResponse success() {
		return success("");
	}

	public static PageListResponse success(String message) {
		return success(message, null);
	}
	public static <T> PageListResponse<T> success(PageList<T> data) {
		return success("操作成功", data);
	}

	public static <T> PageListResponse<T> success(String message, PageList<T> data) {
		return new PageListResponse(Constants.SUCCESS, message, data);
	}

	public static PageListResponse failure(String code, String message) {
		return failure(code, message, null);
	}

	public static <T> PageListResponse<T> failure(String code, String message, PageList<T> data) {
		return new PageListResponse<>(code, message, data);
	}

}
